<?php


	namespace app\api\validate;


	use think\Request;
	use think\Validate;

	class BaseValidate extends Validate
	{
		/**
		 * 场景验证
		 * @param $scene  场景值：如登录时,注册时
		 *
		 * @return bool|mixed 通过返回true  没有通过返回错误信息
		 * @param
		 * @throws
		 *
		 */
		public function goSceneCheck($scene){
			$request = Request::instance();

			if(!$this->scene($scene)->check($request->param())){
				return ['code'=>-1,'msg'=>$this->error];
			}
			return true;
		}

		/**
		 * 直接验证
		 * @return bool|mixed
		 * @param
		 * @throws
		 *
		 */
		public function goCheck(){
			$request = Request::instance();

			if(!$this->check($request->param())){
				return ['code'=>-1,'msg'=>$this->error];
			}
			return true;
		}


		/**
		 * 判断是否为空
		 * @param $data
		 *
		 * @return bool  不为空返回true
		 * @param
		 * @throws
		 *
		 */
		protected function isNotEmpty($data){
			return !empty($data) ? true :false;
		}

		/**
		 * 判断是否为正整数
		 * @param $num
		 *
		 * @return bool 是正整数返回true
		 * @param
		 * @throws
		 *
		 */
		protected function isInteger($num){
			return !is_null($num) && is_int($num + 0) ? true : false;
		}



	}





